<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title>个人论坛</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="../../../frm/bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href="../../../frm/bootstrap-3.3.7/css/bootstrap-treeview.css" rel="stylesheet">
  </head>
  <body onload="queryInitData()">
    <div class="panel-heading" style="background-color: #428BCA;color: #ffffff;margin:auto;width:100%">
      <h3 class="panel-title">
        <a href="<%=basePath%>modules/micro/html/micro.jsp"><h1>浩鲸知识库</h1></a>
      </h3>
    </div>
    <ul class="nav nav-tabs nav-pills">
      <li ><a href="#">发表主题</a></li>
      <li ><a href="#">匿名答复</a></li>
      <li ><a href="#">实名答复</a></li>
      <li ><a href="#" onclick="searchSubject()">搜索主题</a></li>
      <li class="dropdown">
        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
          个人相关 <span class="caret"></span>
        </a>
        <ul class="dropdown-menu">
          <li><a href="#">修改密码</a></li>
          <li><a href="#">个人信息</a></li>
          <li class="divider"></li>
          <li><a href="#">我的主题</a></li>
        </ul>
    </ul>
    <div id="treeview" style="margin:auto"/>
    <script src="../../../frm/bootstrap-3.3.7/js/jquery.min.js"></script>
    <script src="../../../frm/bootstrap-3.3.7/js/bootstrap.min.js"></script>
    <script src="../../../frm/bootstrap-3.3.7/js/bootstrap-treeview.js"></script>
    <script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
  	<script type="text/javascript">
      var clickItemStr = "";
      $(function() {
        var defaultData = [
          {
            text: '[人事] 说认真的，绩效奖什么时候能发下来？',
            href: '#child1',
            tags: ['4'],
            nodes: [
              {
                text: '冒公司之大不韪认真的问相关领导，绩效奖什么时候能发下来？谁能给个时间范围！[0027000001]',
                href: '#child1',
                tags: ['2'],
                nodes: [
                  {
                    text: '顶一下，同问',
                    href: '#grandchild1',
                    tags: []
                  },
                  {
                    text: '这里要@软创大领导 一下',
                    href: '#grandchild2',
                    tags: []
                  }
                ]
              },
              {
                text: '这工号，够假',
                href: '#child2',
                tags: []
              }
            ]
          },
          {
            text: '研发楼Ａ３－４会议室的投影仪能否移个位置',
            href: "#",
            tags: ['2'],
            nodes: [
              {
                text: '被电视挡住了，投影仪用不起来，电视屏幕太小，没法看[夏天雪]',
                href: '#child1',
                tags: []
              },
              {
                text: '已处理OK。下次如有问题，可在“ZMP--行政办公---故障单处理”中报修，以便我们及时知道和处理！[0027002559]',
                href: '#child1',
                tags: []
              }
            ]
          },
          {
            text: '[内部转让] 转让 乐视一年会员卡',
            href: '#parent3',
            tags: []
          },
          {
            text: '[食堂]食堂排队时，能不能预留一个横向的半米宽度，供打完饭的人行走',
            href: '#parent4',
            tags: []
          },
          {
            text: '[食堂] 哪个菜你觉得最好吃？',
            href: '#parent4',
            tags: []
          },
          {
            text: '[班车] 景明佳园班车可不可以让师傅每天准时走',
            href: '#parent4',
            tags: []
          },
          {
            text: '江宁区碧水湾稀有跃层，紧邻秦淮河，好房待售！有意加Q465993557',
            href: '#parent4',
            tags: []
          },
          {
            text: '[求助]【寻物启事】寻找一个珍珠白TYPEC转VGA转接头',
            href: '#parent4',
            tags: []
          },
          {
            text: '[内部转让] 周杰伦的演唱会门票。。。。',
            href: '#parent4',
            tags: []
          },
          {
            text: '电脑键盘上你最常用的几个键是什么？',
            href: '#parent4',
            tags: []
          },
          {
            text: '[品牌] 代缴汽车车险，最低的的价格',
            href: '#parent4',
            tags: []
          },
          {
            text: '[食堂] 食堂是不是涨价了',
            href: '#parent4',
            tags: []
          },
          {
            text: '还能匿名么，试试看匿名  ...',
            href: '#parent4',
            tags: []
          },
          {
            text: '[人事] 绩效年终不是薪资的一部分吗？',
            href: '#parent4',
            tags: []
          },
          {
            text: '班车费报销,2017年１月/２月和2016年１２月一起提单，都用２０１６年的票可以吗？',
            href: '#parent4',
            tags: []
          },
          {
            text: '[人事] 绩效年终不是薪资的一部分吗？',
            href: '#parent4',
            tags: []
          },
          {
            text: '[内部转让] 飞利浦（PHILIPS）电动牙刷HX9362/67 ,《星你》同款，全新未拆封的，有需要的吗？',
            href: '#parent4',
            tags: []
          },
          {
            text: '[求助] 研发楼机房谁占用了10.45.43.224地址啊？看操作系统是windows server 2003',
            href: '#parent4',
            tags: []
          },
          {
            text: '[行政] 调休工时不够 新人帖',
            href: '#parent4',
            tags: []
          }
        ];
        var options = {
          color: "#428bca",
          expandIcon: 'glyphicon glyphicon-chevron-right',
          collapseIcon: 'glyphicon glyphicon-chevron-down',
          nodeIcon: 'glyphicon glyphicon-bookmark',
          //onhoverColor: "#86BF4B",
          borderColor: "red",
          showBorder: false,
          showTags: true,
          highlightSelected: true,
          selectedColor: "yellow",
          selectedBackColor: "darkorange",
          //enableLinks: true,
          data: defaultData
        };

        $('#treeview').treeview(options);

        // 收缩所有节点
        $('#treeview').treeview('collapseAll', { silent: false });

        //var expandibleNodes = $('#treeview').treeview('search', [ "冒公司", { ignoreCase: false, exactMatch: false } ]);
        ////展开指定节点
        //$expandibleTree.treeview('expandNode', [ expandibleNodes, { levels: 0, silent: true}]);

        //最后一次触发节点Id
        var lastSelectedNodeId = null;
        //最后一次触发时间
        var lastSelectTime = null;

        function clickNode(event, data) {
          clickItemStr = data.text;
          if ((lastSelectedNodeId || lastSelectedNodeId==0) && lastSelectTime) {
            var time = new Date().getTime();
            var t = time - lastSelectTime;
            if (lastSelectedNodeId == data.nodeId && t < 300) {
              customBusiness(data);
            }
          }
          lastSelectedNodeId = data.nodeId;
          lastSelectTime = new Date().getTime();
        }

        //自定义业务方法
        function customBusiness(data){
          console.log(data.text);
          self.location='pubSubject.html';
        }
        //自定义双击事件
        function customDblClickFun(){
          //节点选中时触发
          $('#treeview').on('nodeSelected', function(event, data) {
            clickNode(event, data)
          });
          //节点取消选中时触发
          $('#treeview').on('nodeUnselected', function(event, data) {
            clickNode(event, data)
          });
        }
        customDblClickFun();
      });

      var isOpen = false;
      function searchSubject() {
        var expandibleNodes = $('#treeview').treeview('search', [ "[人事]", { ignoreCase: false, exactMatch: false } ]);
        //$('#treeview').treeview('selectNode', [ expandibleNodes, { silent: $('#chk-select-silent').is(':checked') }]);
        if(!isOpen) {
          ////展开指定节点
          $('#treeview').treeview('expandNode', [ expandibleNodes, { levels: 0, silent: true}]);
          isOpen = true;
        } else {
          $('#treeview').treeview('collapseNode', [ expandibleNodes, { silent: true }]);
          isOpen = false;
        }
      }

      /**
       * 查询初始化主题数据
       */
      function queryInitData() {
        $.post("/subject/qryInitData.do", {}, function result(data) {
          console.log(data)
        });

        //$.ajax({
        //  data:"",//"name="+$("#name").val(),
        //  type:"POST",
        //  dataType: 'json',
        //  url:"/qryInitData.do",
        //  error:function(data){
        //    alert("出错了！！:"+data.msg);
        //  },
        //  success:function(data){
        //    alert("success:"+data);
        //    //$("#result").html(data.msg) ;
        //  }
        //});
      }
  	</script>
  </body>
